﻿using System;
using System.Collections.Generic;
using System.Text;
using BOHVote.DAL;
using System.Data;

namespace BOHVote.BLL
{
    public static class SysConfigClass
    {
        #region <<  Allow Modify Applyer by Unit and Govren  >>

        public static bool IsAllowModifyApplyer()
        {
            bool returnValue;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowModifyApplyer();

            if (strValue == "0")
                returnValue = false;
            else
                returnValue = true;

            return returnValue;
        }

        public static string AllowModifyApplyer()
        {
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowModifyApplyer();

            return strValue;
        }

        public static bool hasDataModifyApplyer()
        {
            bool returnValue = false;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowModifyApplyer();
            if (!string.IsNullOrEmpty(strValue))
            {
                returnValue = true;
            }

            return returnValue;
        }

        public static bool UpdateAllowModifyApplyer(string ModifyApplyer)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.UpdateAllowModifyApplyer(ModifyApplyer);
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        public static bool InsertAllowModifyApplyer(string ModifyApplyer)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.setAllowModifyApplyer(ModifyApplyer, "A");
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        #endregion

        #region <<  PPT  >>

        public static bool IsAllowUploadPPT()
        {
            bool returnValue;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowUploadPPT();

            if (strValue == "0")
                returnValue = false;
            else
                returnValue = true;

            return returnValue;
        }

        public static bool InsertSwitchSubject(string strSubject, string IsOpen)
        {
            bool returnValue;
            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.InsertSwitchSubject(strSubject, IsOpen);

            if (strValue == 0)
                returnValue = false;
            else
                returnValue = true;

            return returnValue;
        }

        public static bool UpdateSwitchSubject(string strSubject, string IsOpen)
        {
            bool returnValue;
            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.UpdateSwitchSubject(strSubject, IsOpen);

            if (strValue == 0)
                returnValue = false;
            else
                returnValue = true;

            return returnValue;
        }

        public static DataSet  getSwitchSubjects()
        {
            SysConfigProvide scp = new SysConfigProvide();

            return scp.getSwitchSubjects();
        }

        public static string  getSwitchSubject(string strSubject)
        {
            SysConfigProvide scp = new SysConfigProvide();
            return scp.getSwitchSubject(strSubject);
        }

        public static string AllowUploadPPT()
        {
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowUploadPPT();

            return strValue;
        }

        public static bool hasDataAllowUploadPPT()
        {
            bool returnValue = false;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsAllowUploadPPT();
            if (!string.IsNullOrEmpty(strValue))
            {
                returnValue = true;
            }

            return returnValue;
        }

        public static bool UpdateAllowUploadPPT(string AllowPPT)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.UpdateAllowUploadPPT(AllowPPT);
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        public static bool InsertAllowUploadPPT(string AllowPPT)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.setAllowUploadPPT(AllowPPT, "A");
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        #endregion

        public static bool IsShowPeronsLogin()
        {
            bool returnValue;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsShowPersonLogin();

            if (strValue == "0")
                returnValue = false;
            else
                returnValue = true;

            return returnValue;
        }

        public static string ShowPeronsLogin()
        {
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsShowPersonLogin();

            return strValue;
        }
        
        public static bool hasDataShowPerson()
        {
            bool returnValue = false;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.IsShowPersonLogin();
            if (!string.IsNullOrEmpty(strValue))
            {
                returnValue = true;
            }

            return returnValue;
        }

        public static bool UpdateShowPersonLogin(string ShowPerson)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.UpdateIsShowPersonLogin(ShowPerson);
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        public static bool InsertShowPersonLogin(string ShowPerson)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.setIsShowPersonLogin(ShowPerson,"A");
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        public static string getApplyStyle()
        {
            string returnValue = string.Empty;
            SysConfigProvide scp = new SysConfigProvide();
            string strValue = scp.GetConfigApplyStyle();
            if (!string.IsNullOrEmpty(strValue))
            {
                returnValue = strValue;
            }
            return returnValue;
        }

        public static bool UpdateApplyStyle(string ApplyStyle)
        {
            bool returnValue = false;

            SysConfigProvide scp = new SysConfigProvide();
            int strValue = scp.UpdateConfigApplyStyle(ApplyStyle);
            if (strValue != -1)
                returnValue = true;

            return returnValue;
        }

        #region << Test Module >>
        public static DataSet getAllATestModule()
        {
            DataSet dst = new DataSet();
            SysConfigProvide scp = new SysConfigProvide();
            dst =  scp.getAllASubjectTestModule();
            //DataColumn dc = new DataColumn("SubjectName");
            //dst.Tables[0].Columns.Add(dc);
            //foreach (DataRow dr in dst.Tables[0].Rows)
            //{
            //    dr["SubjectName"] = Subject.getSubjectNameBySubjectID(dr["SubjectID"].ToString());
            //}
            return dst;
        }

        public static string getTestModuleBySubjectID(string subjectID)
        {
            SysConfigProvide scp = new SysConfigProvide();
            return scp.GetTestModuleBySubjectID(subjectID);
        }


        public static int UpdateTestModule(string sn,string testModuel)
        {
            SysConfigProvide scp = new SysConfigProvide();
            return scp.UpdateSubjectTestModule(sn, testModuel);
        }

        public static int InsertTestModule(string SubjectID, string testModule)
        {
            SysConfigProvide scp = new SysConfigProvide();
            return scp.InsertSubjectTestModule(SubjectID, testModule);

        }
        #endregion
    }
}
